
const { ccclass, property, requireComponent } = cc._decorator;

@ccclass
@requireComponent(cc.AudioSource)
export default class SoundManager extends cc.Component {

    protected get AudioSource() {
        return this.getComponent(cc.AudioSource);
    }

    @property(cc.AudioClip)
    click: cc.AudioClip = null;

    @property(cc.AudioClip)
    score: cc.AudioClip = null;

    @property(cc.AudioClip)
    gameOver: cc.AudioClip = null;

    @property(cc.AudioClip)
    newBest: cc.AudioClip = null;


    playClick() {
        this.AudioSource.clip = this.click;
        this.AudioSource.play();
    }

    playScore() {
        this.AudioSource.clip = this.score;
        this.AudioSource.play();
    }

    playGameOver() {
        this.AudioSource.clip = this.gameOver;
        this.AudioSource.play();
    }

    playNewBest() {
        this.AudioSource.clip = this.newBest;
        this.AudioSource.play();
    }
}
